#pragma once
#include "regs.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

// Memory Structure Define
template <typename T>
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
#pragma pack(push)
#pragma pack(4)
struct MemoryNode
{
	T *data;
	dword size;
};
#pragma pack(pop)
#elif __linux__
struct MemoryNode
{
	T *data;
	dword size;
};
#endif

// Command type define.
enum CTYPE
{
	Spec,
	Regs,
	RAMs,
	Float
};
enum ConType
{
	EQ = 0x10, // Zero
	GT = 0x20,
	GEQ = 0x30,
	LT = 0x40,
	LEQ = 0x50,
	NEQ = 0x60
};

typedef struct
{
	word arg2;
	byte arg1, name;
} CodeS;

typedef struct
{
	byte r2, r1, rd;
	byte name;
} CodeR;

typedef struct
{
	word address;
	byte regd, name;
} CodeLI;

typedef struct
{
	byte arg2, arg1, arg3, name;
} CodeF;

dword loader();
void selector(dword code);
void TypeS(CodeS *code);
void TypeR(CodeR *code);
void TypeLI(CodeLI *code);
void TypeF(CodeF *code);